package zyn_hy_login;

public class Yh_data
{
	private DB_conn conn;
	private String connId;
	private int id;
	private int id2;
	private int id3;
	private String img;
	private String info;
	private String name;
	private String num;
	private String sign;
	private String tableName;
	private int type_id;
	private String url;
	private String zt;

	public Yh_data(String strconnId)
	{
		this.connId = strconnId;
		this.conn = new DB_conn(strconnId);
		this.tableName = this.conn.getDbTable();
	}

	public Yh_data(String strId, String strconnId)
	{
		this.connId = strconnId;
		this.conn = new DB_conn(strconnId);
		this.tableName = this.conn.getDbTable();
		String strSql = " select * from " + this.tableName + " where id = " + strId;
		DataRow row = this.conn.getDataBySql(strSql).Tables[0].Rows[0];
		this.id = (Integer) row.getItem("id");
		this.id2 = (Integer) row.getItem("id2");
		this.id3 = (Integer) row.getItem("id3");
		this.name = row.getItem("name").toString().trim();
		this.num = row.getItem("num").toString().trim();
		this.info = row.getItem("info").toString().trim();
		this.zt = row.getItem("zt").toString().trim();
		this.img = row.getItem("img").toString().trim();
		this.url = row.getItem("url").toString().trim();
		this.sign = row.getItem("sign").toString().trim();
		this.type_id = (Integer) row.getItem("type_id");
	}

	public final int DelData(String strid)
	{
		String strSql = ("delete " + this.tableName + " where id = ") + " '" + strid + "'";
		try
		{
			this.conn.excuteSql(strSql);
		}
		catch (java.lang.Exception e)
		{
			return 0;
		}
		return 1;
	}

	public final String getMaxId(String strsign)
	{
		int num;
		String strSql = "";
		switch (strsign)
		{
			case "u":
				strSql = " select max(id) as mid from " + this.tableName + " where id<59999 and id>=20000 ";
				break;

			case "r":
				strSql = " select max(id) as mid from " + this.tableName + " where id<69999 and id>=60000 ";
				break;

			case "p":
				strSql = " select max(id) as mid from " + this.tableName + " where id<99999 and id>=80000 ";
				break;

			case "f":
				strSql = " select max(id) as mid from " + this.tableName + " where id<199999 and id>=100000 ";
				break;

			default:
				strSql = " select max(id) as mid from " + this.tableName + " where  id>=200000 ";
				break;
		}
		DataRow row = this.conn.getDataBySql(strSql).Tables[0].Rows[0];
		String s = "";
		if (!row.IsNull(0))
		{
			s = row.getItem("mid").toString().trim();
		}
		else
		{
			switch (strsign)
			{
				case "u":
					s = "19999";
//C# TO JAVA CONVERTER TODO TASK: There is no 'goto' in Java:
					goto Label_018B;

				case "r":
					s = "59999";
//C# TO JAVA CONVERTER TODO TASK: There is no 'goto' in Java:
					goto Label_018B;

				case "p":
					s = "79999";
//C# TO JAVA CONVERTER TODO TASK: There is no 'goto' in Java:
					goto Label_018B;

				case "f":
					s = "99999";
//C# TO JAVA CONVERTER TODO TASK: There is no 'goto' in Java:
					goto Label_018B;
			}
			s = "199999";
		}
	Label_018B:
		num = Integer.parseInt(s) + 1;
		return String.valueOf(num);
	}

	public final String getName(String strId)
	{
		String strSql = " select name from " + this.tableName + " where id = " + strId;
		DataRow row = this.conn.getDataBySql(strSql).Tables[0].Rows[0];
		return row.getItem("name").toString().trim();
	}

	public final int getNameCount(String pid, String cname, String zt)
	{
		String strSql = " select id from " + this.tableName + " where name='" + cname + "'and zt='" + zt + "' and id2=" + pid;
		return this.conn.excuteSqlCount(strSql);
	}

	public final String getNewId(String strpid)
	{
		int num = Integer.parseInt(strpid);
		if ((0x4e20 <= num) && (num < 0xea5f))
		{
			return this.getMaxId("u");
		}
		if ((0xea60 <= num) && (num < 0x1116f))
		{
			return this.getMaxId("r");
		}
		if ((0x13880 <= num) && (num < 0x1869f))
		{
			return this.getMaxId("p");
		}
		if ((0x186a0 <= num) && (num < 0x30d3f))
		{
			return this.getMaxId("f");
		}
		return this.getMaxId("5");
	}

	public final String getParentId(String strId)
	{
		String strSql = " select id2 from " + this.tableName + " where type_id<>1 and id = " + strId;
		DataRow row = this.conn.getDataBySql(strSql).Tables[0].Rows[0];
		return row.getItem("id2").toString().trim();
	}

	public final String getProUrl()
	{
		DataRow row = DBCommon.getDataBySqluniquetempvar.Tables[0].Rows[0];
		return row.getItem("url").toString().trim();
	}

	public final int InsertData()
	{
		String strSql = ((((((((((("insert into " + this.tableName + "(id,id2,id3,name,num,info,zt,img,url,sign,type_id) values( ") + " " + String.valueOf(this.id) + ",") + " " + String.valueOf(this.id2) + ",") + " " + String.valueOf(this.id3) + ",") + " '" + this.name + "',") + " '" + this.num + "',") + " '" + this.info + "',") + " '" + this.zt + "',") + " '" + this.img + "',") + " '" + this.url + "',") + " '" + this.sign + "',") + " " + String.valueOf(this.type_id) + " )";
		try
		{
			this.conn.excuteSql(strSql);
		}
		catch (java.lang.Exception e)
		{
			return 0;
		}
		return 1;
	}

	public final int UpdateData()
	{
		Object obj2 = ((((((((((" update " + this.tableName + " set ") + "id2 = " + String.valueOf(this.id2) + ",") + "id3 = " + String.valueOf(this.id3) + ",") + "name = '" + this.name + "',") + "num = '" + this.num + "',") + "info = '" + this.info + "',") + "zt = '" + this.zt + "',") + "img = '" + this.img + "',") + "url = '" + this.url + "',") + "sign = '" + this.sign + "',") + "type_id= " + String.valueOf(this.type_id);
		String strSql = String.Concat(new Object[] {obj2, "where id = ", this.id, ""});
		try
		{
			this.conn.excuteSql(strSql);
		}
		catch (java.lang.Exception e)
		{
			return 0;
		}
		return 1;
	}

	public final String getConnId()
	{
		return this.connId;
	}
	public final void setConnId(String value)
	{
		this.connId = value;
	}

	public final int getId()
	{
		return this.id;
	}
	public final void setId(int value)
	{
		this.id = value;
	}

	public final int getId2()
	{
		return this.id2;
	}
	public final void setId2(int value)
	{
		this.id2 = value;
	}

	public final int getId3()
	{
		return this.id3;
	}
	public final void setId3(int value)
	{
		this.id3 = value;
	}

	public final String getImg()
	{
		return this.img;
	}
	public final void setImg(String value)
	{
		this.img = value;
	}

	public final String getInfo()
	{
		return this.info;
	}
	public final void setInfo(String value)
	{
		this.info = value;
	}

	public final String getName()
	{
		return this.name;
	}
	public final void setName(String value)
	{
		this.name = value;
	}

	public final String getNum()
	{
		return this.num;
	}
	public final void setNum(String value)
	{
		this.num = value;
	}

	public final String getSign()
	{
		return this.sign;
	}
	public final void setSign(String value)
	{
		this.sign = value;
	}

	public final String getTableName()
	{
		return this.tableName;
	}
	public final void setTableName(String value)
	{
		this.tableName = value;
	}

	public final int getType_id()
	{
		return this.type_id;
	}
	public final void setType_id(int value)
	{
		this.type_id = value;
	}

	public final String getUrl()
	{
		return this.url;
	}
	public final void setUrl(String value)
	{
		this.url = value;
	}

	public final String getZt()
	{
		return this.zt;
	}
	public final void setZt(String value)
	{
		this.zt = value;
	}
}